package com.beans;

/**
 * 单例设计模式
 * @author acoffee
 * @create 2021-09-01 20:54
 */
public class SourceDataSingle {

    //保证储存连接信息的是同一个对象
    private static SourceDataSingle singleSourceData = null;

    private SourceDataSingle() {}

    public static SourceDataSingle getInstance() {
        //利用双夹去创建单例
        if (singleSourceData == null) {
            synchronized (SourceDataSingle.class) {
                if (singleSourceData == null) {
                   singleSourceData = new SourceDataSingle();
                }
            }
        }
        return singleSourceData;
    }

    private String sourceIP;
    private String sourcePort;
    private String targetIP;
    private String targetPort;

    public String getSourceIP() {
        return sourceIP;
    }

    public void setSourceIP(String sourceIP) {
        this.sourceIP = sourceIP;
    }

    public String getSourcePort() {
        return sourcePort;
    }

    public void setSourcePort(String sourcePort) {
        this.sourcePort = sourcePort;
    }

    public String getTargetIP() {
        return targetIP;
    }

    public void setTargetIP(String targetIP) {
        this.targetIP = targetIP;
    }

    public String getTargetPort() {
        return targetPort;
    }

    public void setTargetPort(String targetPort) {
        this.targetPort = targetPort;
    }

    @Override
    public String toString() {
        return "SourceDataSingle{" +
                "sourceIP='" + sourceIP + '\'' +
                ", sourcePort='" + sourcePort + '\'' +
                ", targetIP='" + targetIP + '\'' +
                ", targetPort='" + targetPort + '\'' +
                '}';
    }
}
